<?php

require_once ('includes/clanconfig.php');

$db_connect = mysqli_connect($host, $userDB, $passDB, $db);

$players = mysqli_query($db_connect, 'SELECT * FROM `player_info` ORDER BY `epoch` ASC');
$clan = mysqli_query($db_connect, 'SELECT * FROM `clan_info`');

?>
<!--<div id="clan-color">-->
<?php
while ($row = mysqli_fetch_array($clan)) {
	echo "<div class=\"background-clan-profile\" style=\"background: none repeat scroll 0% 0% " . $row['color'] . "\">";
	echo "<img onload=\"$(this).parent().css('background', '" . $row['color'] . "');\" alt=\"\" src=\"/img/cont-img-mask.png\">";
	echo "</div>";
	echo "<div id=\"clan-block\">";
	echo "<div id=\"clan-image\"><img src=\"" . $row['emblem'] . "\" height=\"64px\" width=\"64px\"></div>";
	echo "<div id=\"clan-name\"><p><span style=\"color:" . $row['color'] . "\">[</span>" . $row['abbr'] . "<span style=\"color:" . $row['color'] . "\">]</span> ";echo "<span style=\"color:#f9d088\">" . $row['name'] . "</span></p></div>";
	echo "<div id=\"clan-motto\"><p>" . stripslashes($row['motto']) . "</p></div>";
	echo "<div id=\"clan-descr\"><p>" . stripslashes($row['description']) . "</p></div>";
	echo "</div>";

}
?>
<table style="width:100%; border-collapse:collapse;">
    <tr>
        <td style="border: 1px solid #555; padding: 5px; font-weight:bold; font-size: 14px; text-align: center;">Ник</td>
        <td style="border: 1px solid #555; padding: 5px; font-weight:bold; font-size: 14px; text-align: center;">Звание</td>
        <td style="border: 1px solid #555; padding: 5px; font-weight:bold; font-size: 14px; text-align: center;">Вступил</td>
        <td style="border: 1px solid #555; padding: 5px; font-weight:bold; font-size: 14px; text-align: center;">Боев</td>
        <td style="border: 1px solid #555; padding: 5px; font-weight:bold; font-size: 14px; text-align: center;">% Побед</td>
        <td style="border: 1px solid #555; padding: 5px; font-weight:bold; font-size: 14px; text-align: center;">Ср. опыт за бой</td>
    </tr>
<?php
while ($row = mysqli_fetch_array($players)) {
	$epoch = $row['epoch'];

	$dt = new DateTime("@$epoch");
	$battles = round($row['all_battles'] / 1000);
	echo "<tr>";
	echo "<td style='border: 1px solid #555; padding-left: 5px;'><b>" . $row['name'] . "</b></td>";
	echo "<td style='border: 1px solid #555; padding-left: 5px;'>" . $row['role_i18n'] . "</td>";
	echo "<td style='border: 1px solid #555; padding-right: 5px; text-align: right;'>" . $dt->format('d.m.Y') . "</td>";
	echo "<td style='border: 1px solid #555; padding-right: 5px; text-align: right;'>" . $battles . "K</td>";
	echo "<td style='border: 1px solid #555; padding-right: 5px; text-align: right;'>" . $row['all_winrate'] . "%</td>";
	echo "<td style='border: 1px solid #555; padding-right: 5px; text-align: right;'>" . $row['all_battle_avg_xp'] . "</td>";
	echo "</tr>";
}
?>
<!--</div>-->
